<?php
$mode = 'cv';
// Macro List
if($mode == 1)
{
	for($i="A";$i != "AA";$i++)
	{
		for($j="A";$j != "AA";$j++)
		{
			$letters =  $i.$j;
			$macro = "URL GOTO=http://www.mines-saint-etienne.org/gene/main.php?base=1021#top_annuaire<br>";
			$macro .= "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:maj ATTR=NAME:checkbox1 CONTENT=YES";
			$macro .= "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:maj ATTR=NAME:nom_recherche CONTENT=$letters<br>";
			$macro .= "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:maj ATTR=NAME:Submit&&VALUE:Recherche<br>";
			$macro .= "SAVEAS TYPE=CPL FOLDER=* FILE=$letters<br>";
			echo $macro;
		}
	}
}
elseif($mode = 'det')
{
	$dir = _TEMP_."ENMSE/V2/More/";
	if ($dh = opendir($dir)) 
	{
		$exit = false;
		
		while (($file = readdir($dh)) !== false && !$exit) 
		{
			if(filetype($dir.$file) != 'file')
			{
				continue;
			}					
			$macro = null;
			$letters = substr($file,0,3);
			$name = $letters;
			for($i="A";$i!="AA";$i++)
			{
				$filename = $letters.$i;
				$macro .= "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:maj ATTR=NAME:checkbox1 CONTENT=YES<br>";
				$macro .= "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:maj ATTR=NAME:nom_recherche CONTENT=$filename<br>";
				$macro .= "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:maj ATTR=NAME:Submit&&VALUE:Recherche<br>";
				$macro .= "SAVEAS TYPE=CPL FOLDER=* FILE=$filename<br>";
			}
			echo $macro;
		}
		closedir($dh);
	}
}
elseif($mode == 'cv')
{
	$query = Fox\Dao::infos(Student::classname())->handle()->createQueryBuilder();
	$query->select('reference','fname','lname','cv')
			->from('student_enm','t');
			
	$macro .= "SAVEAS TYPE=CPL FOLDER=* FILE=$filename<br>";		
}
// Macro Detail
// http://www.mines-saint-etienne.org/gene/generer_identite_xml.php?det=63c3ddcc7b23daa1e42dc41f9a44a873